package com.itheima.youdianda.common;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

/**
 * @author 袁鹏
 * @date 2022-09-07-16:19
 */
@Component
public class CommonFieldHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue("updateDate", LocalDate.now());
        metaObject.setValue("createDate", LocalDate.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateDate", LocalDate.now());
    }
}
